package tests;

import java.util.ArrayList;

import javax.swing.JPasswordField;
import javax.swing.JTextField;

import junit.framework.TestCase;
import models.Empleados;
import models.Roles;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import Interfaz.EmpleadosWindow;
import Interfaz.LoginWindow;
import connection.HibernateUtil;

public class TestInsertEmpleados extends TestCase {

	static Empleados empleado;
	static EmpleadosWindow ventanaEmpleados;
	static Roles rol;
	ArrayList<String> dnis;
	boolean firstTime = true;
	
	@BeforeClass
	public static void setUpClass() throws Exception {
	
	}

	@AfterClass
	public static void tearDownClass() throws Exception {
		// Liberaci�n de recursos, escritura en el log...
		
	}

	@Before
	public void setUp() {
		// Inicializaci�n de variables antes de cada Test
		if(firstTime){
		dnis = new ArrayList<String>();
		for (int i = 0; i < 101; i++) {
			dnis.add(Integer.toString(i));
		}
		LoginWindow login = new LoginWindow();
		login.exec = new LoginWindow();
		login.dniText = new JTextField();
		login.passText = new JPasswordField();
		login.dniText.setText("12345678q");
		login.passText.setText("1234");
		login.DAO = HibernateUtil.configureSessionFactory().getCurrentSession();
		login.DAO.beginTransaction();
		
		empleado = login.doLogin();
		firstTime = false;
		}
		ventanaEmpleados = new EmpleadosWindow(empleado);
		rol = ventanaEmpleados.rolesObj.get(0);
	}

	@After
	public void tearDown() {
		
	}

	@Test
	public void testMethod1() throws Exception {
			boolean result = true;
			for (int i = 0; i < 100; i++) {
				
				ventanaEmpleados.createNewEmpleado("test"+dnis.get(i), "apellido"+dnis.get(i), "apellido"+dnis.get(i), dnis.get(i), 1234, "test", 1234, "test", "1234", rol, "1234", ventanaEmpleados.generateByteImage("test.png"));
				ventanaEmpleados.inflateList("");
				System.out.println(i);
			}
			assertTrue(true);
	}

}
